import java.time.LocalDateTime;

public class Billing {
    public static double calculateCost(final int callDuration, final LocalDateTime startTime) {
        // 将通话时长向上进位到分钟
        int callMinutes = (int) Math.ceil((double) callDuration / 60);

        double cost = 0;
        if (callMinutes <= 1 && callMinutes > 0) {
            cost = 0.05;
        } else if (callMinutes <= 20 && callMinutes > 1) {
            cost = callMinutes * 0.05;
        } else if (callMinutes > 20 && callMinutes <= 108000) {
            cost = 1 + (callMinutes - 20) * 0.1;
        } else {
            cost = -1.0;
        }

        // 如果是夏令时转换点，并且通话开始时间在调整前的最后一分钟内，则按照通话时长计费，模拟
        if (startTime.getHour() == 2 && startTime.getMinute() < 59 && callMinutes > 0 && callMinutes <= 108000) {
            cost += (callMinutes <= 1) ? 0.05 : ((callMinutes - 1) * 0.05);
        }

        return cost;
    }

}
